package org.example.asm;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;

import java.io.File;
import java.io.FileOutputStream;

/**
 * @author : yuhuan.wu
 * @date : 2021/10/26
 * @description :
 */
public class Generator {
    public static void main(String[] args) throws Exception {
        //读取
        ClassReader classReader = new ClassReader("com.cc.mathAndStructure.unUserfulTest.Base");
        ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        //处理
        ClassVisitor classVisitor = new MyClassVisitor(classWriter);
        classReader.accept(classVisitor, ClassReader.SKIP_DEBUG);
        byte[] data = classWriter.toByteArray();
        //输出
//        File f = new File("D:\\genTest.class");
        File f = new File("D:\\GOWORK\\MyAllProject\\math-and-structure\\target\\classes\\com\\cc\\mathAndStructure\\unUserfulTest\\Base.class");

        FileOutputStream fout = new FileOutputStream(f);
        fout.write(data);
        fout.close();
        System.out.println("now generator cc success!!!!!");

//        Class<?> aClass = Class.forName("org.aopalliance.aop.AspectException");
//
//        System.out.println(aClass.getName());

    }




}
